package interface_test;

/**
 * @author yuisama
 * @date 2022/09/15 21:16
 **/
public class Test {
    public static void main(String[] args) {
        Cat cat = new Cat();
        Dog dog = new Dog();
        Duck duck = new Duck();
        runTest(cat);
        runTest(dog);
        runTest(duck);
        swimTest(dog);
        swimTest(duck);
        flyTest(duck);
    }
    // 定义这个方法时，采用的都是接口参数，接收所有该接口的子类
    // 都属于向上转型(多态)
    public static void runTest(IRun iRun) {
        iRun.run();
    }

    public static void swimTest(ISwim iSwim) {
        iSwim.swim();
    }

    public static void flyTest(IFly iFly) {
        iFly.fly();
    }
}